const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
const { rightWardSvgSrc } = require('../../../utils/iconSvg')
const nearbyColor = '#ff593d';
const { wholeHouseSvgSrc, flatShareSvgSrc, shortRentSvgSrc, needHouseSvgSrc } = require('../../../utils/iconSvg')
const myModuleArr = [{ iconSrc: wholeHouseSvgSrc(nearbyColor), text: '我的房源', urlParam:'/pages/nuan/my-house/myHouse'}, { iconSrc: flatShareSvgSrc(nearbyColor), text: '浏览记录',urlParam:'/pages/nuan/collect/collectHouse' }, { iconSrc: shortRentSvgSrc(nearbyColor), text: '我的访客',urlParam:'/pages/nuan/select2/select2?otherSelectedVal=7' }, { iconSrc: needHouseSvgSrc(nearbyColor), text: '我的求租',urlParam:'/pages/nuan/select2/select2?rentType=0'},
]
const { voiceSvgSrc, maleSvgSrc, femaleSvgSrc } = require('../../../utils/iconSvg')
const defaultColor = '#A6A6A6'
// const defaultColor = 'rgba(153,153,153, 1)';
const activeColor = 'rgba(255, 127, 80)';
const app = getApp()
const ip = app.globalData.ipStr
Page({

    /**
     * 页面的初始数据
     */
    data: {
        defaultAvatarUrl: defaultAvatarUrl,
        avatarUrl:'',
        nickName: '微信用户',
        wxno: 'df大都会',
        rightWardSvgSrc: rightWardSvgSrc('#A6A6A6'),
        userInfoVO:{},
        houseInfoPageVOLPage:{},
        houseNeedPageVOPage:{},
        voiceSvgSrc: voiceSvgSrc(defaultColor),
        maleSvgSrc: maleSvgSrc(defaultColor), 
        femaleSvgSrc: femaleSvgSrc(defaultColor),
        myModuleArr:myModuleArr,
    },
    /**
     * 点击我的页面模块
     * @param {我的页面模块}} e 
     */
    clickModule(e){
        var url = e.currentTarget.dataset.url
        console.info('url=' + url)
        wx.navigateTo({
            url: url,
            success: function (res) {
                console.info('打开info页面成功')
            },
            fail: function (e) {
                console.info('打开info页面失败，e=' + JSON.stringify(e))
            }
        })
    },
    getMainData(id){
        wx.request({
            url: 'http://' + ip + '/weixin/getMainData?current=' + 1,
            method: 'POST',
            header: {
                'Authorization': wx.getStorageSync("token"),
                'content-type': 'application/json;charset=UTF-8'
            },
            data: {},
            success: res => { //wx.request成功的回调
                console.info('加载用户主页详细信息返回信息=' + JSON.stringify(res))
                if (res.statusCode == 200) {
                    var mainVO = res.data.data
                    this.setData({userInfoVO:mainVO.userInfoVO, houseInfoPageVOLPage:mainVO.houseInfoPageVOLPage,
                        houseNeedPageVOPage:mainVO.houseNeedPageVOPage})
                    
                    if(mainVO == null){
                        console.error('加载用户主页详细数据异常，请检查')
                    }
                }
            }
        })
    },



    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        if (wx.getStorageSync("token")) {
            this.getMainData();
        } else {
            app.login_1128_2().then(tokenStr => {
                this.getMainData();
            })
        }
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})